/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package intelligenttm.SourceFile;

import intelligenttm.ITMGUIMainController;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.embed.swing.SwingNode;
import me.aviator.entity.Symbol;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.dom.Document;
import org.w3c.dom.svg.SVGDocument;

/**
 *
 * @author 望舒凌霄
 */
public class SymbolShow {
    String name="";
    SwingNode SN=new SwingNode();
    JSVGCanvas svgCanvas = new JSVGCanvas();

    public SymbolShow() {
    }

    public SymbolShow(Symbol S) {
        name=S.getName();
        InputStream is = new ByteArrayInputStream(S.getSvgxml()); 
        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory SAXSVGDF = new SAXSVGDocumentFactory(parser);
        Document doc=null;
        try {
            doc = SAXSVGDF.createDocument(null,is);
        } catch (IOException ex) {
            Logger.getLogger(ITMGUIMainController.class.getName()).log(Level.SEVERE, null, ex);
        }
        svgCanvas.setDocument(doc);
        SN.setContent(svgCanvas);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public SwingNode getSN() {
        return SN;
    }

    public void setSN(SwingNode SN) {
        this.SN = SN;
    }

    public JSVGCanvas getSvgCanvas() {
        return svgCanvas;
    }

    public void setSvgCanvas(JSVGCanvas svgCanvas) {
        this.svgCanvas = svgCanvas;
        SN.setContent(svgCanvas);
    }
    
    
}
